import request from '@/utils/request.js'

export const getGoodsList = (params) => {
  return request({
    url: '/goods',
    method: 'get',
    params
  })
}

export const putGoods = (data) => {
  return request({
    url: `/goods/${data.goods_id}`,
    method: 'put',
    data
  })
}

export const delGoods = (id) => {
  return request({
    url: `/goods/${id}`,
    method: 'delete'
  })
}

export const getSearch = (params) => {
  return request({
    url: '/goods',
    method: 'get',
    params
  })
}

export const getCategories = () => {
  return request({
    url: '/categories'
  })
}

export const postGoods = (data) => {
  return request({
    url: '/goods',
    method: 'post',
    data
  })
}

// 获取商品参数
export const getParamsCategories = (id, params) => {
  return request({
    url: `/categories/${id}/attributes`,
    params
  })
}

// 更新动态参数里的tag
export const putAttributes = (data) => {
  return request({
    url: `/categories/${data.cat_id}/attributes/${data.attr_id}`,
    method: 'put',
    data
  })
}

// 添加参数

export const addCategories = (data) => {
  return request({
    url: `/categories/${data.cat_id}/attributes`,
    method: 'post',
    data
  })
}
// 删除参数
export const delCategories = (data) => {
  return request({
    url: `/categories/${data.cat_id}/attributes/${data.attr_id}`,
    method: 'delete'
  })
}

export const getCategories1 = (params) => {
  return request({
    url: '/categories',
    params
  })
}
